﻿
@{
    ViewBag.Title = "库位库存";
    Layout = "~/Views/Shared/_LayoutPage.cshtml";
    var warehouses = ViewBag.Warehouses as List<IOA.MES.DataAccess.VModel.VUserWarehouse>;
}

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">仓库：</label>
                    <div class="layui-input-inline">
                        <select id="selWarehouses" lay-filter="selWarehouses">
                            @foreach (var item in warehouses)
                            {
                                <option value="@item.WarehouseCode" selected>@item.WarehouseName</option>
                            }
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">库区：</label>
                    <div class="layui-input-inline">
                        <select id="selAreas" lay-filter="selAreas">
                            <option value="">所有库区</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">库位：</label>
                    <div class="layui-input-inline">
                        <select id="selLocations" lay-filter="selLocations">
                            <option value="">所有库位</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <button id="btnSearch" class="layui-btn layuiadmin-btn-list" type="button">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </div>
    </div>

    <div class="layui-card">
        <div class="layui-card-body">
            <table id="table" lay-filter="table"></table>
        </div>
    </div>
</div>

@section Scripts{
    <script>
        initLayui();
        function initLayui() {
            layui.use(['table', 'layer', 'laydate', 'form'], function () {
                var layer = layui.layer,
                    table = layui.table,
                    laydate = layui.laydate,
                    form = layui.form;

                var options = {
                    elem: '#table'
                    , url: '/Warehouse/QueryLocationStorages'
                    , method: "post"
                    , where: { warehouseCode: "", areaCode: "", location: "" }
                    , response: {
                        statusName: 'ErrCode'
                        , statusCode: 200
                        , msgName: 'ErrCode'
                        , countName: 'TotalCount'
                        , dataName: 'Data'
                    }
                    , page: {
                        limit: 15
                        , limits: [15, 20, 25, 30, 40, 50]
                    }
                    , cols: [[
                        { title: '序号', type: "numbers", width: 60 }
                        , { field: 'WarehouseName', title: '仓库', width: 100}
                        , { field: 'CustomerWarehouseName', title: '客户仓库', width: 100 }
                        , { field: 'Location', title: '库位', width: 120 }
                        , { field: 'PackNo', title: '打包编号', width: 200 }
                        , { field: 'ProductCode', title: '成品料号', width: 200 }
                        , { field: 'ProductName', title: '成品名称', width: 200 }
                        , { field: 'ProductSpecs', title: '成品规格', width: 200 }
                        , { field: 'Quantity', title: '包装数量', width: 100 }
                        , { field: 'DetailQuantity', title: '组件数量', width: 100 }
                        , { field: 'CreateTimeStr', title: '入库时间', width: 160 }
                    ]]
                };

                $("#btnSearch").click(function () {
                    queryTable();
                });
                queryTable();
                function queryTable() {
                    options.where.warehouseCode = $("#selWarehouses").val().trim();
                    options.where.areaCode = $("#selAreas").val().trim();
                    options.where.location = $("#selLocations").val().trim();

                    if (table.index <= 0) {
                        table.render(options);
                    } else {
                        table.reload("table", options);
                    }
                }
            });
        }
    </script>
}
